﻿using System.Windows;
using DeploymentCopy.Helper;
using DeploymentCopy.ViewModel;

namespace DeploymentCopy
{
    /// <summary>
    /// This application's main window.
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Closing += (s, e) => ViewModelLocator.Cleanup();
            Loaded += (s, e) =>
                          {
                              MainViewModel vm = this.DataContext as MainViewModel;
                              switch (vm.DeployMode)
                              {
                                  case EnumDeployMode.Staging:
                                      gridData.Columns[0].Visibility = Visibility.Visible;
                                      gridData.Columns[1].Visibility = Visibility.Hidden;
                                      break;
                                  case EnumDeployMode.Product:
                                      gridData.Columns[0].Visibility = Visibility.Hidden;
                                      gridData.Columns[1].Visibility = Visibility.Visible;
                                      break;
                                  default:
                                      gridData.Columns[0].Visibility = gridData.Columns[1].Visibility = Visibility.Hidden;
                                      break;
                              }
                          };
        }

        private void cboMode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (gridData == null)
                return;
            switch (((MainViewModel)this.DataContext).DeployMode)
            {
                case EnumDeployMode.Staging:
                    gridData.Columns[0].Visibility = Visibility.Visible;
                    gridData.Columns[1].Visibility = Visibility.Hidden;
                    break;
                case EnumDeployMode.Product:
                    gridData.Columns[0].Visibility = Visibility.Hidden;
                    gridData.Columns[1].Visibility = Visibility.Visible;
                    break;
                default:
                    gridData.Columns[0].Visibility = gridData.Columns[1].Visibility = Visibility.Hidden;
                    break;
            }
        }
    }
}